package net.lab1024.smartadmin.module.business.vehicleConfiguration.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import net.lab1024.smartadmin.common.domain.PageResultDTO;
import net.lab1024.smartadmin.common.domain.ResponseDTO;
import net.lab1024.smartadmin.module.business.vehicleConfiguration.dao.VehicleConfigurationDao;
import net.lab1024.smartadmin.module.business.vehicleConfiguration.domain.dto.VehicleConfigurationAddDTO;
import net.lab1024.smartadmin.module.business.vehicleConfiguration.domain.dto.VehicleConfigurationQueryDTO;
import net.lab1024.smartadmin.module.business.vehicleConfiguration.domain.dto.VehicleConfigurationUpdateDTO;
import net.lab1024.smartadmin.module.business.vehicleConfiguration.domain.entity.VehicleConfigurationEntity;
import net.lab1024.smartadmin.module.business.vehicleConfiguration.domain.vo.VehicleConfigurationExcelVO;
import net.lab1024.smartadmin.module.business.vehicleConfiguration.domain.vo.VehicleConfigurationVO;
import net.lab1024.smartadmin.util.SmartBeanUtil;
import net.lab1024.smartadmin.util.SmartPageUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * [ �������� ]
 *
 * @author �Ζ�
 * @version 1.0
 * @company ��������
 * @copyright (c)  ��������Inc. All rights reserved.
 * @date 2021-11-19 11:20:38
 * @since JDK1.8
 */
@Service
public class VehicleConfigurationService {

    @Autowired
    private VehicleConfigurationDao vehicleConfigurationDao;

    /**
     * ����id��ѯ
     */
    public VehicleConfigurationEntity getById(Long id){
        return  vehicleConfigurationDao.selectById(id);
    }

    /**
     * ��ҳ��ѯ
     * @author �Ζ�
     * @date 2021-11-19 11:20:38
     */
    public ResponseDTO<PageResultDTO<VehicleConfigurationVO>> queryByPage(VehicleConfigurationQueryDTO queryDTO) {
        Page page = SmartPageUtil.convert2QueryPage(queryDTO);
        IPage<VehicleConfigurationVO> voList = vehicleConfigurationDao.queryByPage(page, queryDTO);
        PageResultDTO<VehicleConfigurationVO> pageResultDTO = SmartPageUtil.convert2PageResult(voList);
        return ResponseDTO.succData(pageResultDTO);
    }

    /**
     * ���
     * @author �Ζ�
     * @date 2021-11-19 11:20:38
     */
    public ResponseDTO<String> add(VehicleConfigurationAddDTO addDTO) {
        VehicleConfigurationEntity entity = SmartBeanUtil.copy(addDTO, VehicleConfigurationEntity.class);
        vehicleConfigurationDao.insert(entity);
        return ResponseDTO.succ();
    }

    /**
     * �༭
     * @author �Ζ�
     * @date 2021-11-19 11:20:38
     */
    @Transactional(rollbackFor = Exception.class)
    public ResponseDTO<String> update(VehicleConfigurationUpdateDTO updateDTO) {
        VehicleConfigurationEntity entity = SmartBeanUtil.copy(updateDTO, VehicleConfigurationEntity.class);
        vehicleConfigurationDao.updateById(entity);
        return ResponseDTO.succ();
    }

    /**
     * ɾ��
     * @author �Ζ�
     * @date 2021-11-19 11:20:38
     */
    @Transactional(rollbackFor = Exception.class)
    public ResponseDTO<String> deleteByIds(List<Long> idList) {
        vehicleConfigurationDao.deleteByIdList(idList);
        return ResponseDTO.succ();
    }

    /**
     * ��ѯȫ����������
     * @author �Ζ�
     * @date 2021-11-19 11:20:38
     */
    public List<VehicleConfigurationExcelVO> queryAllExportData(VehicleConfigurationQueryDTO queryDTO) {
        return vehicleConfigurationDao.queryAllExportData( queryDTO);
    }

    /**
     * ������ѯ��������
     * @author �Ζ�
     * @date 2021-11-19 11:20:38
     */
    public List<VehicleConfigurationExcelVO> queryBatchExportData(List<Long> idList) {
        return vehicleConfigurationDao.queryBatchExportData(idList);
    }
}
